﻿using Microsoft.EntityFrameworkCore;
using Polaris.Domain.Model.DbEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using static System.Net.Mime.MediaTypeNames;

namespace Polaris.EntityFrameworkCore
{
    public class PolarisDbContext : DbContext
    {
        public PolarisDbContext(DbContextOptions<PolarisDbContext> options)
          : base(options)
        {
        }


        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            #region 数据库实体配置

            //唯一约束
            modelBuilder.Entity<Sys_Dictionary>()
               .HasIndex(e => e.Code)
               .IsUnique();

            #endregion

            base.OnModelCreating(modelBuilder);

        }

        public DbSet<Sys_User> Sys_User { get; set; }

        public DbSet<WebSite> Web_Site { get; set; }

        public DbSet<Sys_Dictionary> Sys_Dictionary { get; set; }

        public DbSet<Sys_Dictionary_Item> Sys_Dictionary_Item { get; set; }

        public DbSet<ArticleContent> ArticleContent { get; set; }

        public DbSet<ArticleInfo> ArticleInfo { get; set; }

        public DbSet<ArticleDictionaryRelation> ArticleDictionaryRelation { get; set; }

        public DbSet<Sys_Menu> Sys_Menu { get; set; }

        public DbSet<Sys_MenuRole> Sys_MenuRole { get; set; }

        public DbSet<Sys_UserMenu> Sys_UserMenu { get; set; }

        public DbSet<Tag> Tag { get; set; }

        public DbSet<UnifyMessage> UnifyMessage { get; set; }

        public DbSet<Sys_Role> Sys_Role { get; set; }

        public DbSet<Sys_UserRole> Sys_UserRole { get; set; }

        public DbSet<Notes> Notes { get; set; }
    }
}
